<?php

namespace app\api\controller\admin;

use app\common\controller\Api;
use think\Db;

/**
 * 软件列表接口
 */
class Xtemail extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
    public function index()
    {
        $this->success('请求成功66555');
    }

    /**
     * 查看
     */
    public function gindex()
    {
        $params = $this->request->param();
        $action =$params['action'];
        if($action=='apiindex'){
            $data= self::apiindex();
            return $data;
        }elseif ($action=='apiadd'){
            self::apiadd();
        }elseif ($action=='apiedit'){
            self::apiedit();
        }elseif ($action=='apidel'){
            self::apidel();
        }
    }

    /**
     * 查看
     */
    public function apiindex()
    {

        $list = Db::table('fa_g_xtemail')
            ->find();
        $this->success('',$list);

    }
    public function apiadd()
    {
        $post = $this->request->post();
        unset($post['action']);
        $post['createtime']=time();
        $list=Db::table('fa_g_xtemail')->insertGetId($post);

        $this->success($list);

    }
    public function apiedit()
    {
        $post = $this->request->post();
        unset($post['action']);

        $post['updatetime']=time();
        $list=Db::table('fa_g_xtemail')
            ->where('id',1)
            ->update($post);
        $this->success($list);

    }
    public function apidel()
    {
        $post = $this->request->post();
        unset($post['action']);
        $list=Db::table('fa_g_xtemail')->delete($post);
        $this->success($list);

    }
}
